package com.charles.entity;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.concurrent.atomic.AtomicLong;

@Data
@AllArgsConstructor
public class IdBlock {

    AtomicLong nextId;
    long lastId;

    public boolean useful() {
        return lastId >= nextId.get();
    }

    public long nextId() {
        long _nextId = nextId.getAndIncrement();
        return _nextId;
    }
}